﻿Public Class ucMuaHang
    'biến lưu tên user control nhấn vào sau cùng
    Public TenUserControl As String

    'Hàm thêm user control lên  pnMuaHang
    Public Sub ThemUserControl(uc As UserControl)
        If uc.Name <> TenUserControl Then
            TenUserControl = uc.Name
            pnMuaHang.Controls.Clear()
            uc.Dock = DockStyle.Fill
            pnMuaHang.Controls.Add(uc)
        End If
    End Sub

    Private Sub ucMuaHang_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Dim uc As New ucPhieuNhapHang
        uc.Dock = DockStyle.Fill
        pnMuaHang.Controls.Add(uc)
        TenUserControl = uc.Name
        lbTieuDe.Text = btnPhieuNhapHang.Caption
    End Sub

    Private Sub btnPhieuNhapHang_LinkClicked(sender As Object, e As DevExpress.XtraNavBar.NavBarLinkEventArgs) Handles btnPhieuNhapHang.LinkClicked
        Dim uc As New ucPhieuNhapHang
        lbTieuDe.Text = btnPhieuNhapHang.Caption
        ThemUserControl(uc)
        navBarDanhMuc.Visible = True
    End Sub

    Private Sub btnTheoChungTu_LinkClicked(sender As Object, e As DevExpress.XtraNavBar.NavBarLinkEventArgs) Handles btnTheoChungTu.LinkClicked
        Dim uc As New ucTheoChungTuMH
        lbTieuDe.Text = "Bảng Kê Tổng Hợp"
        ThemUserControl(uc)
        navBarDanhMuc.Visible = False
    End Sub

    Private Sub btnTheoHangHoa_LinkClicked(sender As Object, e As DevExpress.XtraNavBar.NavBarLinkEventArgs) Handles btnTheoHangHoa.LinkClicked
        Dim uc As New ucTheoHangHoaMH
        lbTieuDe.Text = "Bảng Kê Chi Tiết"
        ThemUserControl(uc)
        navBarDanhMuc.Visible = False
    End Sub

    Private Sub btnHangHoa_LinkClicked(sender As Object, e As DevExpress.XtraNavBar.NavBarLinkEventArgs) Handles btnHangHoa.LinkClicked
        Dim frm As New frmThemHangHoa
        frm.ShowDialog()
    End Sub

    Private Sub btnKhachHang_LinkClicked(sender As Object, e As DevExpress.XtraNavBar.NavBarLinkEventArgs) Handles btnKhachHang.LinkClicked
        Dim frm As New frmThemKhachHang
        frm.ShowDialog()
    End Sub

    Private Sub btnKhoHang_LinkClicked(sender As Object, e As DevExpress.XtraNavBar.NavBarLinkEventArgs) Handles btnKhoHang.LinkClicked
        Dim frm As New frmThemKhoHang
        frm.ShowDialog()
    End Sub
End Class
